Gets an
ICollection containing the keys of the
IDictionary.
Syntax
Example
Library/Library.Test/TestLurchTable.cs
C# | Copy Code |
---|
var sample = GetSample();
var items = CreateSample(sample);
IDictionary<int, string> dict = items;
var keys = new List<int>();
foreach (var kv in sample)
keys.Add(kv.Key);
VerifyCollection(EqualityComparer<int>.Default, keys.AsReadOnly(), items.Keys);
VerifyCollection(EqualityComparer<int>.Default, keys.AsReadOnly(), dict.Keys); |
VB.NET | Copy Code |
---|
Dim sample As var = GetSample()
Dim items As var = CreateSample(sample)
Dim dict As IDictionary(Of Integer, String) = items
Dim keys As var = New List(Of Integer)()
For Each kv As var In sample
keys.Add(kv.Key)
Next
VerifyCollection(EqualityComparer(Of Integer).[Default], keys.AsReadOnly(), items.Keys)
VerifyCollection(EqualityComparer(Of Integer).[Default], keys.AsReadOnly(), dict.Keys) |
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also